package com.yf.dxapp.module.app.dal.mysql.material;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import com.yf.dxapp.module.app.controller.admin.material.vo.MaterialPageReqVO;
import com.yf.dxapp.module.app.dal.dataobject.material.MaterialDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 素材信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface MaterialMapper extends BaseMapperX<MaterialDO> {

    default PageResult<MaterialDO> selectPage(MaterialPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MaterialDO>()
                .eqIfPresent(MaterialDO::getTitle, reqVO.getTitle())
                .eqIfPresent(MaterialDO::getProductId, reqVO.getProductId())
                .eqIfPresent(MaterialDO::getProductType, reqVO.getProductType())
                .eqIfPresent(MaterialDO::getCover, reqVO.getCover())
                .eqIfPresent(MaterialDO::getCoverImgMaterialUrl, reqVO.getCoverImgMaterialUrl())
                .eqIfPresent(MaterialDO::getSimpleTitle, reqVO.getSimpleTitle())
                .eqIfPresent(MaterialDO::getUrl, reqVO.getUrl())
                .eqIfPresent(MaterialDO::getPromotion, reqVO.getPromotion())
                .eqIfPresent(MaterialDO::getVideoUrl, reqVO.getVideoUrl())
                .betweenIfPresent(MaterialDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MaterialDO::getId));
    }

}